﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>视频课程</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link href="../../static/css/font.css" rel="stylesheet" />
    <link href="../../static/css/weadmin.css" rel="stylesheet" />
    <link href="../../lib/layui/css/layui.css" rel="stylesheet" />
    <script src="../../../lib/layui/layui.js"></script>
</head>
<body>
    <div class="weadmin-nav">
        <span class="layui-breadcrumb" style="visibility: visible;">
            <a href="#">首页</a><span lay-separator="">/</span>
            <a href="#">查询统计</a><span lay-separator="">/</span>
            <a><cite>培训课程及视频查询</cite></a>
        </span>
        <a class="layui-btn layui-btn-sm" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
            <i class="layui-icon" style="line-height:30px">ဂ</i>
        </a>
    </div>
    <div class="layui-fluid fluid-position">
        <div class="layui-form">
            <div class="layui-card">
                <!--<div class="layui-card-header">
                    <div class="layui-row layui-col-space10 layui-btn-container">

                    </div>
                </div>-->
                <div class="layui-card-body">
                    <div class="layui-form layui-form-pane">
                        <div class="layui-form-item">
                            <label class="layui-form-label">课程名称</label>
                            <div class="layui-input-inline">
                                <input type="text" placeholder="课程名称" maxlength="50" class="layui-input" id="TCOName" name="TCOName" />
                            </div>
                            <!--<label class="layui-form-label">培训计划</label>
                            <div class="layui-input-inline">
                                <input type="text" placeholder="培训计划" maxlength="50" class="layui-input" id="PrePlanName" name="PrePlanName" onclick="SelectGroup()" />
                            </div>-->
                            <!--<label class="layui-form-label">培训教师</label>
                            <div class="layui-input-inline">
                                <select id="TrainTeacherName" name="TrainTeacherName" lay-filter="TrainTeacherName">
                                    <option value=""></option>
                                </select>
                            </div>

                            <label class="layui-form-label">教室</label>
                            <div class="layui-input-inline">
                                <select id="CRName" name="CRName" lay-filter="CRName">
                                    <option value=""></option>

                                </select>
                            </div>-->

                            <div class="layui-inline">
                                <label class="layui-form-label">起止时间</label>
                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input" id="StartDateTime" />
                                </div>
                                <label class="layui-form-label layui-form-label-inner layui-form-label-inner-w1">至</label>
                                <div class="layui-input-inline layui-form-label-inner">
                                    <input type="text" class="layui-input" id="EndDateTime" name="EndDateTime" />
                                </div>
                            </div>
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <button type="button" class="layui-btn layui-btn-primary" id="find" name="查询"><i class="layui-icon">&#xe615;</i>查询</button>
                                    <button type="button" class="layui-btn layui-btn-primary" id="reset" name="清空"><i class="layui-icon">&#xe669;</i>清空</button>
                                </div>
                            </div>
                            <!--<div class="layui-inline">
                                <label class="layui-form-label">发布</label>
                                <div class="layui-input-block">
                                    <select id="IsRelease" class="layui-tree-more" name="IsRelease">
                                        <option value="">请选择</option>
                                        <option value="0">未发布</option>
                                        <option value="1">已发布</option>
                                    </select>
                                </div>
                            </div>-->
                        </div>
                        <!--时间-->
                        <!--<div class="layui-form-item">
                            <div class="layui-form-label">选择部门</div>
                            <div class="layui-input-block">
                                <input type="text" autocomplete="off" readonly="" id="selectDatas" name="selectDatas" placeholder="请选择" class="layui-input" />
                                <div class="eleTree" lay-filter="data5"></div>
                            </div>
                        </div>-->


                    </div>
                </div>
                <!--<div class="layui-card-header layui-btn-container">

                </div>-->
            </div>
        </div>
    </div>
    <div class="layui-fluid" id="infos">
        <table id="dataList" lay-filter="dataList"></table>
        <script id="barDemo" type="text/html">
            <a class="layui-btn layui-btn-sm layui-btn-normal" lay-event="Play">视频课程</a>
            <a class="layui-btn layui-btn-sm layui-btn-normal" lay-event="detail">学习记录</a>
        </script>
    </div>


    <script>
        var ModleNameTip = "培训课程";  //模块名称  用于提示部门信息的内容
        var contollerName = "TrainCourse";
        var load = 1;
        var CPID = 0;//所属集团计划id  带过来的 或者直接选过来的
        var refTPID = 0;//携带过来的计划id
        var prePlanId = 0;//选择的上级培训计划id
        var selectIDs = [];//选中的id列表 [可用批量删除  审核 取消 ]
        var selectCurrentID = 0;// 当前选中的 id  [用于修改]
        var currentDeptLevelId = 0;//当前登录者 部门级别  0：是段
        var currentInfoDeptLevelId = 0;//当前选中信息的  部门级别  [用于判断 是否能够对 该条信息进行修改:下级不能对上级的计划信息进行修改]
        var cuurentDeptId = 0;//当前部门id

        var selectCurrentIsCheckStatus = 0;// 当前选中的行的 IsChck 状态  [用于删除/审核/取消审核/发布/取消发布时判断]
        var selectCurrentIsReleaseStatus = 0;// 当前选中的行的 IsRelease 状态  [用于删除/审核/取消审核/发布/取消发布时判断]

        var currentInfoDeptId = 0;//当前选中信息的 部门id
        var selectobjs = [];//
        var CurrentSelectCRID = 0;//当前选择信息的教室id
        var FileListIds = [];//选择的文件资料id 列表
        var currentTCOName = "";
        var teacherList = [];//教师列表
        var classRoom = [];//教室列表
        //加载 [赋值]获取数据  (部门相关数据)
        var dataSelect = [];
        var temp_deptId_List = [];//列表中选择信息时   使用字段中的内容=>为其赋值,可以使用此字段保存
        var dataCurent = [];
        var th = 0;
        var tw = 0;
        //选择上级计划/集团计划 【段筛选 集团计划， 下级都筛选培训计划  根据当前部门级别来判断， 段是0】

        function CourseContentDetailRep(v) {
            //if (selectCurrentID == 0) {
            //    layer.msg("请选择课程信息!"); return;
            //}
            layui.use(['layer', 'jquery'], function () {
                var h = th * 1.8;
                var w = tw * 0.4;
                var layer = layui.layer;
                var $ = layui.jquery;
                var contentPage = "CourseStudyRecorder.html?TCOID=" + v + "";
                var title = "课程学习记录";
                layer.open({
                    title: title,
                    type: 2,
                    area: [w + "px", h + "px"],
                    //btn: ['确定'],
                    content: contentPage,
                    yes: function (index) {
                        //var res = window["layui-layer-iframe" + index].selectdata();
                        //$("#PrePlanName").val(res.RefName);
                        //prePlanId = res.RefID;
                        //CPID = res.CPID;
                        layer.close(index);
                    }
                });
            });
        };
        layui.use(['form', 'laydate', 'table', 'jquery', 'element', 'layer', 'tree', 'util'], function () {
            var laydate = layui.laydate;
            var $ = layui.jquery;
            th = $(document).height() * 0.5;
            tw = $(document).width();
            var table = layui.table;
            var form = layui.form;
            var element = layui.element;
            var layer = layui.layer;
            var eleTree = layui.tree;
            $(".layui-card-header").find("button").each(function () { if (PowerList.indexOf($(this).attr("name")) <= -1) { $(this).attr("style", "display:none;") } });
            form.on('switch(switch)', function (data) { });
            var d = new Date();
            var ds = new Date();
            ds = addDate(d, -7);

            function addDate(date, days) {
                var d = new Date(date);
                d.setDate(d.getDate() + days);
                var m = d.getMonth() + 1;
                return d.getFullYear() + '-' + m + '-' + d.getDate();
            }
            laydate.render({ elem: '#StartDateTime', trigger: 'click', type: 'date', value: ds });
            laydate.render({ elem: '#EndDateTime', trigger: 'click', type: 'date', value: d });
            function PageInit() {
                var obj = $("div[lay-id='dataList']");
                var child = $(".layui-table-body");
                var off = obj.offset().top;
                var c = th;
                child.attr("style", "height:" + c + "px");
            }
            element.on('collapse(infos_form)', function (data) {
                PageInit();
            });
            function formRenderSelect() {
                form.render('select');
            }
            function SelectGroup(starTime, endTime) {
                //if (selectCurrentID == 0) {
                //    layer.msg("请选择培训课程!");
                //    return;
                //}
                //if ($("#StartDateTime").val() == "") {
                //    layer.msg("没有开始日期");
                //    return;
                //}
                //if ($("#StartDateTime").val() == "") {
                //    layer.msg("没有结束日期");
                //    return;
                //}
                var StartDateTime = starTime;// $("#StartDateTime").val();
                var EndDateTime = endTime;//$("#EndDateTime").val();
                var szUsername = "";
                var szPassword = "";
                var szIP = "";
                var szPort = "";
                var iRtspPortValue = "";
                $.ajax({
                    url: ApiUrl + "AttendanceDev/GetByCRID?CRID=" + CurrentSelectCRID,
                    type: 'get',
                    headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    },
                    success: function (data) {

                        if (data.StatusCode == 200) {
                            if (data.Data.length > 0) {
                                var item = data.Data[0];
                                szUsername = item.DVRLoginUserID;
                                szPassword = item.DVRLoginPwd;
                                szIP = item.DVRIP;
                                szPort = item.LocalPort;
                            }
                            if (szUsername == "") {
                                layer.msg("硬盘录像机用户名不能为空");
                                return;
                            }
                            if (szPassword == "") {
                                layer.msg("硬盘录像机密码不能为空");
                                return;
                            }
                            if (szIP == "") {
                                layer.msg("硬盘录像机IP地址没有配置");
                                return;
                            }
                            if (szPort == "") {
                                layer.msg("硬盘录像机访问端口没有设置,一般为80");
                                return;
                            }
                            //if (iRtspPortValue == "") {
                            //    layer.msg("硬盘录像机RTSP端口没有设置,一般为554");
                            //    return;
                            //}
                            layui.use(['layer', 'jquery'], function () {
                                var h = th * 1.8;
                                var w = tw * 0.8;
                                var layer = layui.layer;
                                var $ = layui.jquery;
                                var contentPage = "../search/VediosPlay.html?szStartTime=" + StartDateTime + "&szEndTime=" + EndDateTime + "&szUsername=" + szUsername + "&szPassword=" + szPassword + "&szIP=" + szIP + "&szPort=" + szPort + "&iRtspPortValue=" + iRtspPortValue + "";
                                var title = currentTCOName;
                                layer.open({
                                    title: title,
                                    type: 2,
                                    area: [w + "px", h + "px"],
                                    //btn: ['确定'],
                                    content: contentPage,
                                    yes: function (index) {
                                        //var res = window["layui-layer-iframe" + index].selectdata();
                                        //$("#PrePlanName").val(res.RefName);
                                        //prePlanId = res.RefID;
                                        ////CPID = res.CPID;
                                        //refTPID = res.TPID;
                                        layer.close(index);
                                    }
                                });

                            });
                        }
                        else if (data.StatusCode == 403) {
                            layer.alert(data.Info, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                        else {
                            layer.msg(data.Info);
                        }
                    }
                });


            };
            //读取教室数据
            function GetRoom(DeptID) {
                $.ajax({
                    url: ApiUrl + "TrainClassRoom/Sel",
                    type: 'post',
                    headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    },
                    data: { '': JSON.stringify(DeptID) },
                    success: function (data) {
                        if (data.StatusCode == 200) {
                            for (var i = 0; i < data.Data.length; i++) {
                                var item = data.Data[i];
                                classRoom.push({ id: item.CRID, name: item.CRName });
                            }
                            GetSelectList(classRoom, $("#CRName"), formRenderSelect);
                        }
                        else if (data.StatusCode == 403) {
                            layer.alert(data.Info, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                        else {
                            layer.msg(data.Info);
                        }
                    }
                });
            }
            //读取教师数据
            function GetTeacher(DeptID) {
                $.ajax({
                    url: ApiUrl + "TrainTeacher/Sel",//SelTree
                    type: 'post',
                    headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    },
                    data: { '': JSON.stringify(DeptID) },
                    success: function (data) {
                        if (data.StatusCode == 200) {
                            for (var i = 0; i < data.Data.length; i++) {
                                var item = data.Data[i];
                                teacherList.push({ id: item.TeacherID, name: item.TeacherName });
                            }
                            GetSelectList(teacherList, $("#TrainTeacherName"), formRenderSelect);
                        }
                        else if (data.StatusCode == 403) {
                            layer.alert(data.Info, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                        else {
                            layer.msg(data.Info);
                        }
                    }
                });
            }
            //获取当前 部门级别id,部门id
            $.ajax({
                url: ApiUrl + "Dep/DeptLevel",//SelTree
                type: 'post',
                headers: {
                    "userid": JSON.parse(window.localStorage.authInfo).UserId,
                    "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                },
                success: function (data) {
                    if (data.StatusCode == 200) {
                        currentDeptLevelId = data.Data.currentDeptLevelId;
                        cuurentDeptId = data.Data.cuurentDeptId;
                        GetDept(cuurentDeptId);
                        GetRoom(cuurentDeptId);
                        GetTeacher(cuurentDeptId);
                    }
                    else if (data.StatusCode == 403) {
                        layer.alert(data.Info, function () {
                            top.location.href = "http://" + top.location.host + "/login.html";
                        })
                    }
                    else {
                        layer.msg(data.Info);
                    }
                }
            });

            //获取下级部门列表树
            function GetDept(deptid) {
                var r = 0;
                $.ajax({
                    url: ApiUrl + "Dep/SelNextTree",//SelTree
                    type: 'post',
                    async: false,
                    headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    },
                    data: { DepID: deptid },
                    success: function (data) {
                        if (data.StatusCode == 200) {
                            dataSelect = data.Data;
                            loadTree();
                            r = 1;
                        }
                        else if (data.StatusCode == 403) {
                            layer.alert(data.Info, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                        else {
                            layer.msg(data.Info);
                        }
                    }
                });
                return r;
            }

            var tempList = [];
            function SetTextFromTree(v) {
                for (var i = 0; i < v.length; i++) {
                    var c = v[i];
                    tempList.push({ id: c.id, title: c.title });
                    temp_deptId_List.push(c.id);
                    var a = $("#selectDatas").val();
                    if (a != "") { a += ","; }
                    $("#selectDatas").val(a + c.title);
                    if (c.children != undefined) {
                        if (c.children.length > 0) {
                            SetTextFromTree(c.children);
                        }
                    }
                }
            }

            function setTree()//选择信息列表中 信息时 调用该方法  并为temp_deptId_List赋值
            {
                eleTree.setChecked('eleTreeid', temp_deptId_List);
            }

            var el_tree;
            $("#selectDatas").on("click", function (e) {
                e.stopPropagation();
                loadTree();
                $(".eleTree").toggle();
            });

            function loadTree() {
                el_tree =
                    eleTree.render({
                        elem: '.eleTree',
                        id: 'eleTreeid',
                        data: dataSelect,
                        defaultExpandAll: false,
                        expandOnClickNode: false,
                        highlightCurrent: true
                        , checkStrictly: true
                        , showCheckbox: true
                        , oncheck: function (obj) {
                            $("#selectDatas").val("");
                            temp_deptId_List = [];
                            tempList = [];
                            SetTextFromTree(el_tree.getChecked());
                        }
                    });
            }
            function showList() {
                var swhere = JSON.stringify({
                    StartDateTime: $("#StartDateTime").val(),
                    EndDateTime: $("#EndDateTime").val() + " 23:59:59",
                    IsRelease: $("#IsRelease").val(),
                    TCOName: $("#TCOName").val(),
                    IsUse: 1,
                    self: 3
                });
                table.render({
                    elem: '#dataList'
                    , url: ApiUrl + contollerName + '/Search'
                    , id: "dataList"
                    , headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    }
                    , page: true
                    , cols: [[
                        { type: 'checkbox' },
                        { field: 'AutoID', title: 'AutoID', sort: true, hide: true },
                        { field: 'TPID', title: '计划id', sort: true, hide: true },
                        { field: 'TCID', title: '授课内容id', sort: true, hide: true },
                        { field: 'TCOID', title: '编号', sort: true, hide: true },
                        { field: 'CRID', title: '教室编号', sort: true, hide: true },
                        { field: 'TCOName', title: '课程名称', width: 300 },
                        { field: 'CRName', title: '教室', width: 120 },
                        { field: 'TrainTeacherID', title: '培训教师ID', hide: true },
                        { field: 'TrainTeacherName', title: '培训教师', width: 120 },
                        { field: 'Duration', title: '时长(分钟)', width: 100 },
                        {
                            field: 'StartDateTime', title: '开始时间', width: 120, sort: true, templet: function (d) {
                                if (d.StartDateTime != undefined) {
                                    return d.StartDateTime.substring(0, 10);
                                }
                                else {
                                    return "";
                                }
                            },
                        },
                        {
                            field: 'EndDateTime', title: '结束时间', width: 120, sort: true, templet: function (d) {
                                if (d.EndDateTime != undefined) {
                                    return d.EndDateTime.substring(0, 10);
                                }
                                else {
                                    return "";
                                }
                            },
                        },
                        { field: 'DepID', title: '部门id', hide: true },
                        { field: 'DepLevel', title: '部门级别id', hide: true },
                        { field: 'AddUserID', title: '添加人员id', hide: true },
                        { field: 'AddUserName', title: '添加人员姓名', width: 120 },
                        {
                            field: 'AddDateTime', title: '添加时间', width: 120, templet: function (d) {
                                if (d.AddDateTime != undefined) {
                                    return d.AddDateTime.substring(0, 10);
                                }
                                else {
                                    return "";
                                }
                            },
                        },
                        { field: 'SendDepID', title: '下发部门id', hide: true },
                        {
                            field: 'IsCheck', title: '审核', width: 100, templet: function (d) {
                                return d.IsCheck == "0" ? "未审核" : "已审核";
                            }
                        },
                        //{
                        //    field: 'IsRelease', title: '发布', width: 100, templet: function (d) {
                        //        return d.IsRelease == "0" ? "未发布" : "已发布";
                        //    }
                        //},
                        //{ field: 'IsUse', title: '使用状态', width: 100, templet: function (d) { return d.IsUse == "0" ? "未用" : "在用" } }
                        { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 180 },
                    ]]
                    , where: { swhere: swhere }
                    , parseData: function (res) { //res 即为原始返回的数据
                        return {
                            "code": res.StatusCode, //解析接口状态
                            "msg": res.Info, //解析提示文本
                            "count": res.Count, //解析数据长度
                            "data": res.Data //解析数据列表
                        };
                    },
                    response: { statusCode: 200 },//规定成功的状态码，默认：0
                    event: true,
                    page: true,
                    done: function (res, curr, count) {
                        //如果是异步请求数据方式，res即为你接口返回的信息。
                        //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
                        if (res.data != null) {
                            var p = $(".layui-laypage-skip").find("input[type=text]").val();
                            var c = $(".layui-laypage-limits select").find("option:selected").text().substring(0, 2);
                            var k = (Number(p) - 1) * Number(c);
                            for (var i = 0; i < res.data.length; i++) {
                                var item = res.data[i];
                                var ix = item.Row - 1 - k;
                                $(".layui-table-body table tbody tr[data-index=" + ix + "]").attr("style", dataRowColor[item.TPDepLevel]);
                            }
                        }
                        if (res.code == 403) {
                            layer.alert(res.msg, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                    }
                });
            }
            showList();
            PageInit();
            function clearForm() {
                $("textarea").val("");
                $("input").val("");
                $("#IsRelease").val("");
            }
            function GetSinglePrePlanOrCorp(TPID) {
                //选择上级计划
                $.ajax({
                    url: ApiUrl + "TrainPlan/GetSingle?TPID=" + TPID,
                    type: 'get',
                    headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    },
                    success: function (data) {
                        if (data.StatusCode == 200) {
                            $("#PrePlanName").val(data.Data.TPName);
                        }
                        else if (data.StatusCode == 403) {
                            layer.alert(data.Info, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                        else {
                            layer.msg(data.Info);
                        }
                    }
                });
            }
            //读取相关的课程资料内容 传入当前培训课程id
            function GerCourseFiles(TCOID) {
                var courseFileWhere = JSON.stringify({ TCOID: TCOID });
                $.ajax({
                    url: ApiUrl + "TrainCourseFiles/Search",//SelTree
                    type: 'post',
                    headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    },
                    data: { '': courseFileWhere },
                    success: function (data) {
                        if (data.StatusCode == 200) {
                            FileListIds = [];
                            var tempFileNames = [];
                            for (var i = 0; i < data.Data.length; i++) {
                                var item = data.Data[i];
                                FileListIds.push(item.TFID);
                                tempFileNames.push(item.TFName);
                            }
                            $("#PreTFName").val(tempFileNames.toString());
                        }
                        else if (data.StatusCode == 403) {
                            layer.alert(data.Info, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                        else {
                            layer.msg(data.Info);
                        }
                    }
                });
            }
            //展示一条信息
            function GetSingleInfo(data) {
                return;
                //GerCourseFiles(data.TCOID);
                //GetSingleCourseContent(data.TCID);
                var star = data.StartDateTime.substring(0, data.StartDateTime.length - 3).split('T');
                var end = data.EndDateTime.substring(0, data.EndDateTime.length - 3).split('T');
                $("#StartDateTime").val(star[0] + " " + star[1]);
                $("#EndDateTime").val(end[0] + " " + end[1]);
                $("#IsRelease").val(data.IsRelease);
                if (data.TCID != null) {
                    prePlanId = data.TCID;
                    GetSinglePrePlanOrCorp(prePlanId);
                }
                $("#TCOName").val(data.TCOName);
                currentTCOName = data.TCOName;
                SetselectValue($("#TrainTeacherName"), data.TrainTeacherID, formRenderSelect);
                SetselectValue($("#CRName"), data.CRID, formRenderSelect);
                $("#Duration").val(data.Duration);
                //CPID = data.CPID;
                refTPID = data.TPID;
                currentInfoDeptLevelId = data.DepLevel;
                currentInfoDeptId = data.DepID;
                var r = GetDept(currentInfoDeptId);
                if (r == 1) {
                    if (data.SendDepID != null) {
                        if (data.SendDepID.indexOf(',') > -1) {
                            var tpids = data.SendDepID.split(',');
                            for (var i = 0; i < tpids.length; i++) {
                                temp_deptId_List.push(Number(tpids[i]));
                            }
                        }
                        else {
                            temp_deptId_List.push(Number(data.SendDepID));
                        }
                        setTree();
                    }
                }
                //add by cjh
                selectCurrentIsCheckStatus = data.IsCheck;
                selectCurrentIsReleaseStatus = data.IsRelease;
            }
            ///按钮操作 开始
            //监听行工具事件
            table.on('tool(dataList)', function (obj) {
                var data = obj.data;
                if (obj.event === 'detail') {
                    //var start = $("#TPReleaseStart").val();
                    //var endtime = $("#TPReleaseEnd").val();
                    CourseContentDetailRep(obj.data.TCOID);
                }
                if (obj.event === 'Play') {

                    $.ajax({
                        url: ApiUrl + "CameraVideo/SearchForTCOID?TCOID=" + obj.data.TCOID,//SelTree
                        type: 'get',
                        headers: {
                            "userid": JSON.parse(window.localStorage.authInfo).UserId,
                            "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                        },
                        //where: { 'TCOID': obj.data.TCOID },
                        success: function (data) {
                            if (data.StatusCode == 200) {
                                if (data.Data.length > 0) {
                                    var url = DownUrl + data.Data[0].VideoAddress;
                                    var name = data.Data[0].VideoName;

                                    VedioPlay(url, name);
                                    //VedioPlay("http://10.115.101.12:8001//CameraVideo/2019/11/29/085500-103500_21_2.MP4", "北线20191129");

                                }
                            }
                            else if (data.StatusCode == 403) {
                                layer.alert(data.Info, function () {
                                    top.location.href = "http://" + top.location.host + "/login.html";
                                })
                            }
                            else {
                                layer.msg(data.Info);
                            }
                        }
                    });

                    //var star = data.StartDateTime.substring(0, data.StartDateTime.length - 3).split('T');
                    //var end = data.EndDateTime.substring(0, data.EndDateTime.length - 3).split('T');
                    //var starTime = star[0] + " " + star[1];
                    //var endTime = end[0] + " " + end[1];
                    //SelectGroup(starTime,endTime);
                }
            });


            function VedioPlay(v, vedio) {

                var sign = 0; //弹出视频窗体标志
                //alert("浏览器:" + getExplorerInfo().type + "\n 版本:" + getExplorerInfo().version);
                var ExplorerType = getExplorerInfo().type; //浏览器
                var ExplorerVersion = getExplorerInfo().version; //浏览器版本

                if (ExplorerType == 'Firefox') {
                    var version = ExplorerVersion.substr(0, 2);
                    if (version < 70) {
                        alert("你的火狐浏览器版本过低，请下载提供的火狐浏览器！")
                        window.location.href = DownUrl + "uploads/Firefox_70.exe";
                    }
                    else {
                        sign = 1;
                    }
                }
                else {
                    sign = 1;
                }

                if (sign == 1) {
                    var h = th * 1.9;
                    var w = tw * 0.5;
                    layer.open({
                        type: 1,
                        shadeClose: true,
                        shade: 0.3,
                        title: vedio,
                        area: [w + "px", h + "px"],
                        content: play(v),
                    });
                }

            }

            function getExplorerInfo() {
                var explorer = window.navigator.userAgent.toLowerCase();
                //ie
                if (explorer.indexOf("msie") >= 0) {
                    var ver = explorer.match(/msie ([\d.]+)/)[1];
                    return { type: "IE", version: ver };
                }
                //firefox
                else if (explorer.indexOf("firefox") >= 0) {
                    var ver = explorer.match(/firefox\/([\d.]+)/)[1];
                    return { type: "Firefox", version: ver };
                }
                //Chrome
                else if (explorer.indexOf("chrome") >= 0) {
                    var ver = explorer.match(/chrome\/([\d.]+)/)[1];
                    return { type: "Chrome", version: ver };
                }
                //Opera
                else if (explorer.indexOf("opera") >= 0) {
                    var ver = explorer.match(/opera.([\d.]+)/)[1];
                    return { type: "Opera", version: ver };
                }
                //Safari
                else if (explorer.indexOf("Safari") >= 0) {
                    var ver = explorer.match(/version\/([\d.]+)/)[1];
                    return { type: "Safari", version: ver };
                }
            }

            //监听行单击事件（单击事件为：rowDouble）
            table.on('row(dataList)', function (obj) {
                var checked = false;
                var objcheck = $(obj.tr.selector).find("td").eq(0).find(".layui-table-cell").eq(0).find("div").eq(0);
                if (selectIDs.indexOf(obj.data.TCOID) > -1) {
                    objcheck.removeClass("layui-form-checked");
                }
                else {
                    objcheck.addClass("layui-form-checked"); checked = true;
                }
                if (checked) {
                    if (obj.data.TCOID != undefined) {
                        selectCurrentID = obj.data.TCOID;
                        CurrentSelectCRID = obj.data.CRID;
                        selectIDs.push(obj.data.TCOID);
                        selectobjs.push(obj.data);
                        GetSingleInfo(obj.data);
                    }
                    else {
                        selectIDs = [];
                        selectCurrentID = 0;
                        selectobjs = [];
                        CurrentSelectCRID = 0;
                        var dataList = table.checkStatus("dataList").data;
                        for (var i = 0; i < dataList.length; i++) {
                            var item = dataList[i];
                            selectobjs.push(item);
                            selectIDs.push(item.TCOID);
                            if (i == dataList.length - 1) {
                                GetSingleInfo(item);
                                selectCurrentID = item.TCOID;
                                CurrentSelectCRID = item.CRID;
                            }
                        }
                    }
                }
                else {
                    if (obj.data.TCOID != undefined) {
                        selectIDs.splice(selectIDs.indexOf(obj.data.TCOID), 1);
                        for (var i = 0; i < selectobjs.length; i++) {
                            if (selectobjs[i].TCOID == obj.data.TCOID) {
                                if (i == selectobjs.length - 1) {
                                    selectCurrentID = 0;
                                    CurrentSelectCRID = 0;
                                    selectCurrentName = "";
                                    if (i > 0) {
                                        if (selectobjs[i - 1].TCOID != undefined) {
                                            selectCurrentID = selectobjs[i - 1].TCOID;
                                            CurrentSelectCRID = selectobjs[i - 1].CRID;
                                            GetSingleInfo(selectobjs[i - 1]);
                                        }
                                    }
                                    else {
                                        clearForm(); selectCurrentID = 0;
                                    }
                                }
                                selectobjs.splice(i, 1);
                                break;
                            }
                        }
                        if (selectIDs <= 0) {
                            temp_deptId_List = [];
                            var r = GetDept(cuurentDeptId);
                            if (r == 1) {
                                setTree();
                            }
                        }
                    }
                    else {
                        selectIDs = [];
                        selectCurrentID = 0;
                        CurrentSelectCRID = 0;
                        selectobjs = [];
                        clearForm();
                        temp_deptId_List = [];
                        var r = GetDept(cuurentDeptId);
                        if (r == 1) {
                            setTree();
                        }
                    }
                }
            });
            table.on('checkbox(dataList)', function (obj) {
                if (obj.data.AutoID == undefined) {
                    selectIDs = [];
                    selectCurrentID = 0;
                    CurrentSelectCRID = 0;
                    selectobjs = [];
                    if (obj.checked) {
                        var dataList = table.checkStatus("dataList").data;
                        for (var i = 0; i < dataList.length; i++) {
                            var item = dataList[i];
                            selectobjs.push(item);
                            selectIDs.push(item.TCOID);
                            if (i == dataList.length - 1) {
                                GetSingleInfo(item);
                                selectCurrentID = item.TCOID;
                                CurrentSelectCRID = item.CRID;
                            }
                        }
                    }
                    else {
                        selectIDs = [];
                        selectCurrentID = 0;
                        selectobjs = [];
                        clearForm();
                        temp_deptId_List = [];
                        var r = GetDept(cuurentDeptId);
                        if (r == 1) {
                            setTree();
                        }
                    }
                }
            });
            $("#find").click(function () {
                showList();
            });
            $("#reset").click(function () {
                clearForm();
                temp_deptId_List = [];
                selectCurrentID = 0;
                GetDept(cuurentDeptId);
                setTree();
            });
            //校验数据
            function CheckData() {
                if (prePlanId <= 0) {
                    layer.msg("请选择授课内容！");
                    return false;
                }
                if ($("#StartDateTime").val().trim() == "") {
                    layer.msg("请选择开始时间！");
                    return false;
                }
                if ($("#EndDateTime").val().trim() == "") {
                    layer.msg("请选择结束时间！");
                    return false;
                }
                if ($("#Duration").val().trim() == "") {
                    layer.msg("请输入时长(分钟)！");
                    return false;
                }
                return true;
            }
            //获得数据
            function GetFormData() {
                //FileListIds   文件资料id 数组值
                var TPName = $("#TPName").val();//计划名称
                var ID = CPID;//prePlanId;//集团id
                var TCID = prePlanId;// prePlanId;//上级计划id
                var StartDateTime = $("#StartDateTime").val();
                var EndDateTime = $("#EndDateTime").val();
                var Duration = $("#Duration").val();
                var RoomName = $("#CRName option:selected").text();
                var RoomId = $("#CRName").val();
                var TeacherName = $("#TrainTeacherName option:selected").text();
                var TeacherId = $("#TrainTeacherName").val();
                var TCOName = $("#TCOName").val();
                return model = {
                    TCOName: TCOName,
                    TPName: TPName,
                    TPID: refTPID,
                    TCID: TCID,
                    StartDateTime: StartDateTime,
                    EndDateTime: EndDateTime,
                    SendDepID: temp_deptId_List.toString(),
                    Duration: Duration,
                    TrainTeacherID: TeacherId,
                    TrainTeacherName: TeacherName,
                    CRID: RoomId,
                    CRName: RoomName,
                    IsRelease: false,
                    IsCheck: false,
                    IsUse: true
                }
            }
            //判断当前 能否操作该信息
            function GetOperate(operRatetype, pcurrentInfoDeptLevelId) {
                //operRatetype:操作类型     pcurrentInfoDeptLevelId:当前需要操作的信息的  部门级别
                //operRatetype[1:修改，2：删除,3:审核,4:取消审核,5:发布 6:取消发布]
                var result = true;
                if (currentDeptLevelId > pcurrentInfoDeptLevelId) {
                    switch (operRatetype) {
                        case 1:
                            layer.msg("您没有权限，不能修改上级" + ModleNameTip + "");
                            result = false;
                            break;
                        case 2:
                            layer.msg("您没有权限，不能删除上级" + ModleNameTip + "");
                            result = false;
                            break;
                        case 3:
                            layer.msg("您没有审核权限，不能对该条信息进行审核");
                            result = false;
                            break;
                        case 4:
                            layer.msg("您没有取消审核权限，不能对该条信息进行取消审核");
                            result = false;
                            break;
                        case 5:
                            layer.msg("您没有发布信息权限，不能对该条信息进行发布");
                            result = false;
                            break;
                        case 6:
                            layer.msg("您没有取消发布权限，不能对该条信息进行取消发布");
                            result = false;
                            break;
                    }
                }
                return result;
            }
            //$(function () {
            //    $("#Studyrecorder").on("click", function () {
            //        CourseContentDetailRep();
            //    });
            //});

            //视频课程
            //$("#add").click(function () {

            //});
            //end
        });
    </script>
</body>
</html>